/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 * Fullscreen code inspired by http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=javabeginner&Number=30686&page=4&view=collapsed&sb=11&o=&fpart=1
 */

package sim_test;

import javax.swing.*;
import java.awt.Dimension;
import java.awt.*;
import java.awt.Dimension;
import java.awt.BorderLayout;

/**
 *
 * @author Administrator
 */
public class Sim_JFrameMain extends JFrame{

    //Fields
    private Container mainContainer;
    private Sim_ControllerMain simControllerMain;
    private Sim_JScrollMainGraphicsWindow jScrollPaneMainGraphicsWindow;
    private Dimension prefferedSizeNotFullScreen;
    private Dimension sizeOfMainGraphicsWindow;
    private Dimension sizeOfComponentsInMainGraphicsWindow;
    
    private boolean isFullScreen;
    
    
    //Constructor
    public Sim_JFrameMain(Sim_ControllerMain scm)
    {
        //Object creation
        simControllerMain = scm;
        prefferedSizeNotFullScreen = new Dimension(
                (int)(Toolkit.getDefaultToolkit().getScreenSize().getWidth() * 0.85),
                (int)(Toolkit.getDefaultToolkit().getScreenSize().getHeight() * 0.9 ));
        sizeOfMainGraphicsWindow = new Dimension(500,500);
        sizeOfComponentsInMainGraphicsWindow = new Dimension(
                simControllerMain.getCurrentScenario().getSimMap().
                getBackgroundImage().getWidth(null), 
                simControllerMain.getCurrentScenario().getSimMap().
                getBackgroundImage().getHeight(null));
        
        
        
        mainContainer = getContentPane();
        jScrollPaneMainGraphicsWindow = new Sim_JScrollMainGraphicsWindow(
                simControllerMain, sizeOfMainGraphicsWindow, sizeOfComponentsInMainGraphicsWindow);
      
        debugTestBefore();
        createLayout();
        
        
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setPreferredSize(prefferedSizeNotFullScreen);
        
        //mainContainer.setLayout();

        addContentToContainer();
        
        //toggleFullScreen();
        
        pack();
        setVisible(true);
        debugTest();
        
        
        
    
        
    }
    
    private void toggleFullScreen() // code inspired by http://www.javaworld.com/javaforums/showflat.php?Cat=&Board=javabeginner&Number=30686&page=4&view=collapsed&sb=11&o=&fpart=1
    {
        if(isFullScreen)
        {
            setUndecorated(false);
            setPreferredSize(prefferedSizeNotFullScreen);
            isFullScreen = false;
        }
        
        else
        {
            setUndecorated(true);
            //setExtendedState(Frame.MAXIMIZED_BOTH);
            setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize());
            isFullScreen = true;
        }
        
    }
    private void debugTestBefore()
    {

        
    }
    
    private void debugTest()
    {

    }
    
    
    private void createLayout()
    {
       setLayout(new BorderLayout());
    }
   
    
    private void addContentToContainer()
    {     
       mainContainer.add(jScrollPaneMainGraphicsWindow, BorderLayout.CENTER);
       JLabel jlabelDebug1 = new JLabel("JLabel Placeholder1");
       jlabelDebug1.setPreferredSize(new Dimension(100,100));
       JLabel jlabelDebug2 = new JLabel("JLabel Placeholder2");
       jlabelDebug2.setPreferredSize(new Dimension(100,100));
       JLabel jlabelDebug3 = new JLabel("JLabel Placeholder3");
       jlabelDebug3.setPreferredSize(new Dimension(100,100));
       JLabel jlabelDebug4 = new JLabel("JLabel Placeholder4");
       jlabelDebug4.setPreferredSize(new Dimension(100,100));
       JLabel jlabelDebug5 = new JLabel("JLabel Placeholder5");
       jlabelDebug5.setPreferredSize(new Dimension(100,100));
       mainContainer.add(jlabelDebug1, BorderLayout.WEST);
       mainContainer.add(jlabelDebug2, BorderLayout.EAST);
       mainContainer.add(jlabelDebug3, BorderLayout.NORTH);
       mainContainer.add(jlabelDebug4, BorderLayout.SOUTH);
    }
}
